import { BasicColumn,useRender } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { deptSimple, userSimple } from '/@/api/backs/salary/salary';
import { projectSimple } from '/@/api/backs/foundation/foundation';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
  },
  {
    title: '部门',
    dataIndex: 'deptName',
    customRender: ({ record }) => {
      return record.deptName || '--';
    },
  },
  {
    title: '项目',
    dataIndex: 'projectName',
    customRender: ({ record }) => {
      return record.projectName || '--';
    },
  },
  {
    title: '考勤日期',
    dataIndex: 'attendanceDateStr',
    slots: { customRender: 'attendanceDateStr' },
    customRender: ({ record }) => {
      return record.attendanceDateStr || '--';
    },
  },
  {
    title: '考勤类型',
    dataIndex: 'attendanceTypeVal',
  },
  {
    title: '考勤方式',
    dataIndex: 'attendanceStatusVal',
  },
  {
    title: '签到时间',
    dataIndex: 'clockInTime',
    slots: { customRender: 'clockInTime' },
    customRender: ({ record }) => {
      return record.clockInTime || '--';
    },
  },
  {
    title: '签到状态',
    dataIndex: 'clockInClockStatusVal',
  },
  {
    title: '签到地址',
    dataIndex: 'clockInPosition',
  },
  {
    title: '签退时间',
    dataIndex: 'clockOffTime',
    slots: { customRender: 'clockOffTime' },
    customRender: ({ record }) => {
      return record.clockOffTime || '--';
    },
  },
  {
    title: '签退状态',
    dataIndex: 'clockOffClockStatusVal',
  },
  {
    title: '签退地址',
    dataIndex: 'clockOffPosition',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userId',
    label: '员工',
    component: 'ApiSelect',
    colProps: { span: 8 },
    componentProps: {
      api: userSimple,
      labelField: 'nickname',
      valueField: 'id',
      placeholder: '请选择员工',
    },
  },
  {
    field: 'projectId',
    label: '项目',
    component: 'ApiSelect',
    colProps: { span: 8 },
    componentProps: {
      api: projectSimple,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择项目',
    },
  },
  {
    field: 'deptIds',
    label: '部门',
    colProps: { span: 8 },
    component: 'ApiTreeSelect',
    componentProps: {
      placeholder: '请选择部门',
      api: deptSimple,
      labelField: 'name',
      valueField: 'id',
      dropdownStyle: { maxHeight: '400px', overflow: 'auto' },
      replaceFields: {
        children: 'children',
        title: 'name',
        key: 'id',
        value: 'id',
      },
    },
  },
  {
    label: '日期',
    field: 'time',
    component: 'RangePicker',
    colProps: { span: 8 },
    componentProps: {
      valueFormat: 'X',
      showTime: true,
      ranges: { '今日': [moment(), moment()],'本周': [moment().startOf('week'), moment().endOf('week')], '本月': [moment().startOf('month'), moment().endOf('month')] ,'上一月': [moment().month(moment().month() - 1).startOf('month'), moment().month(moment().month() - 1).endOf('month')]}
    },
  },
];

export const formSchema: FormSchema[] = [];
